﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Threading.Tasks;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

namespace WellDone
{
    public sealed partial class GiftCardDialog : Page
    {
        public event EventHandler CloseRequested;
        public bool bCanceled = false;
        public bool bGetBalance, bActivate, bAddValue, bRefund, bSale;
        public decimal decActivateAmount, decAddAmount, decRefundAmount, decSaleAmount;

        public GiftCardDialog()
        {
            this.InitializeComponent();
        }

        private void btnOK_Click(object sender, RoutedEventArgs e)
        {
            // Close the dialog
            if (this.CloseRequested != null)
            {
                // Set values...
                bActivate = rbActivate.IsChecked == true;
                bAddValue = rbAddValue.IsChecked == true;
                bRefund = rbRefund.IsChecked == true;
                bSale = rbSale.IsChecked == true;
                bGetBalance = rbCheckBalanace.IsChecked == true;
                try
                {
                    decActivateAmount = Convert.ToDecimal(tbInitialAmount.Text);
                }
                catch (Exception) { decActivateAmount = (decimal)0.0; }
                try
                {
                    decAddAmount = Convert.ToDecimal(tbAddAmount.Text);
                }
                catch (Exception) { decAddAmount = (decimal)0.0; }
                try
                {
                    decRefundAmount = Convert.ToDecimal(tbRefundAmount.Text);
                }
                catch (Exception) { decRefundAmount = (decimal)0.0; }
                try
                {
                    decSaleAmount = Convert.ToDecimal(tbSaleAmount.Text);
                }
                catch (Exception) { decSaleAmount = (decimal)0.0; }
                // Call the close method...
                this.CloseRequested(this, EventArgs.Empty);
            }
        }

        private void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            // Set "Canceled" 
            bCanceled = true;
            if (this.CloseRequested != null)
            {
                this.CloseRequested(this, EventArgs.Empty);
            }
        }
    }
}
